﻿using System.Collections;
using Simple.Services.System.QHSEViolationCategory.Models;

namespace Simple.Services;

public class DictionaryTreeNodeModel : QHSEDictionaryModel, ITreeNode
{
    /// <summary>
    /// 主键
    /// </summary>
    public new string? Id { get; set; }

    /// <summary>
    /// 父级Id
    /// </summary>
    public string? ParentId { get; set; }

    public List<DictionaryTreeNodeModel> Children { get; set; } = new List<DictionaryTreeNodeModel>();

    public void SetChildren(IList children)
    {
        var nodes = children as List<DictionaryTreeNodeModel>;
        Children = nodes != null ? nodes : new List<DictionaryTreeNodeModel>();
    }

    public static TreeBuilder<DictionaryTreeNodeModel> CreateBuilder(List<DictionaryTreeNodeModel> nodes,string rootId)
    {
        return new TreeBuilder<DictionaryTreeNodeModel>(nodes,rootId);
    }

    public override void ConfigureMapper(Profile profile)
    {
        profile.CreateMap<QHSESysDictionary, MenuTreeNodeModel>();

        profile.CreateMap<MenuTreeNodeModel, QHSESysDictionary>();
    }
}
